<template>
	<view>
		<u-swiper style="margin-top: 64rpx;" :height="360" :list="list" :effect3d="effect3d"
			:indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="swiperClick(list)"
			@change="swiperChange"></u-swiper>
		<!-- 功能模块 -->
		<view
			style="margin: 30rpx;display: flex;flex-direction: row;align-items:center;border-radius: 20rpx;overflow:hidden;">
			<!-- 左侧 -->
			<view style="flex-direction: column;align-items: center;">
				<!-- <u-image ref="uImage" src="../../static/home/homeTicket.png" width="100%" height="100%" mode="aspectFill" :fade="true"
					duration="1000">
					<u-loading size="44" mode="flower" slot="loading"></u-loading>style="width: 240rpx;height: 140rpx;"style="width: 140rpx;height: 140rpx;"
				</u-image> -->
				<block v-for="(item,index) in mainList" :key="index">
					<image :style="{marginTop:'8rpx',marginLeft:index == 1 || 2 ? '16rpx' : '' }"
						:src="item.isClick ? item.image : item.imageDark"
						style="width: 320rpx;height: 150rpx;border-radius: 10%;" @click="mainItemClick(item)"></image>
				</block>
			</view>
			<!-- 右侧 -->
			<!-- <view
				style="width: 470rpx;margin-left: 4rpx;display: flex;flex-direction: row;flex-wrap: wrap;border-top-right-radius: 50rpx;border-bottom-right-radius: 50rpx;overflow: hidden;">
				<block v-for="(item,index) in subList" :key="index">
					<image v-if="item.isClick" :style="{marginTop:'4rpx',marginLeft:index != 0 || 3 || 6 ? '4rpx' : ''}"
						:src="item.isClick ? item.image : item.imageDark" style="width: 180rpx;height: 150rpx;"
						@click="subClick(item)"></image>
				</block>
			</view> -->
		</view>
		<!-- <view>
			<button class="float-button" hover-class="hover-btn-bg" @click="serviceShow=true">
				出行订单
			</button>
		</view> -->
		<!-- 出行百宝箱 -->
		<view style="font-size: 35rpx;font-weight: bolder;margin-left: 30rpx;">业务展示</view>
		<!-- <view style="margin-left: 34rpx;display: flex;flex-direction: row;flex-wrap: wrap;overflow: hidden;">
			<block v-for="(item,index) in subList" :key="index">
				<image :style="{marginTop:'12rpx',marginLeft:index != 0 || 3 || 6 ? '8rpx' : ''}"
					:src="item.isClick ? item.image : item.imageDark" style="width: 160rpx;height: 133rpx;border-radius: 5%;"
					@click="subClick(item)"></image>
			</block>
		</view> -->
		<view style="margin-left: 34rpx;display: flex;flex-direction: row;flex-wrap: wrap;overflow: hidden;">
			<block v-for="(item,index) in subList" :key="index">
				<image :style="{marginTop:'8rpx',marginLeft:index != 0 || 3 || 6 ? '23rpx' : ''}"
					:src="item.isClick ? item.image : item.imageDark"
					style="width: 200rpx;height: 160rpx;border-radius: 5%;" @click="subClick(item)"></image>
			</block>
		</view>
		<!-- <view style="margin: 30rpx;display: flex;flex-wrap: wrap;">
			<view class="guess-item" v-for="(item, index) in infoList" :key="index" @click="treasureChestClick(item)">
				<view class="image" style="position: relative;">
					<image style="width: 100%;height: 100%;" :src="item.image"></image>
					<view
						style="text-overflow: ellipsis;overflow: hidden; background-color: #33333360;position: absolute;bottom: 0;left: 0;right: 0;padding: 10rpx;color: #fff;"
						v-html="item.title"></view>
				</view>
				<view class="title" v-html="item.subTitle"></view>
			</view> 
		</view> -->
		<!-- <u-popup width="600rpx" border-radius="15" v-model="bindPhoneshow" mode="center">
			<view style="display: flex;height: 150rpx;">
				<view style="font-size: 36rpx;font-weight: bolder;width: 600rpx;margin-top: 50rpx;margin-left: 20rpx;">
					客服电话:13328513020</view>
				<view>
					<image src="../../static/home/Phone.png" @click="call"
						style="width: 60rpx;height: 60rpx;padding: 44rpx 20rpx;"></image>
				</view>
			</view>
			<view style="position: absolute;border-bottom: #acb8b4 0.5px solid;width: 100%;margin-top: 10rpx;"></view>
			<view style="display: flex;margin-top: 50rpx;height: 150rpx;">
				<view style="font-size: 36rpx;font-weight: bolder;width: 600rpx;margin-top: 20rpx;margin-left: 20rpx;">
					客服电话:968951</view>
				<view>
					<image src="../../static/home/Phone.png" @click="call1"
						style="width: 60rpx;height: 60rpx;padding: 10rpx 20rpx;"></image>
				</view>
			</view>
		</u-popup> -->
		<view style="width: 648rpx;display: flex;margin:54rpx;border-radius: 12rpx;overflow: hidden;margin-top: 15rpx;">
			<ad unit-id="adunit-b4895af1f5dfafb7" @close="adClose" @error="adError"></ad>
		</view>
		<!-- #ifdef MP-WEIXIN -->
		<jh-authorize></jh-authorize>
		<!-- #endif -->
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	var _self;
	import jhAuthorize from '@/components/jh-authorize/jh-authorize.vue';
	import indexList from '@/common/js/index.list.js';
	// 在页面中定义插屏广告
	let interstitialAd = null
	export default {
		components: {
			jhAuthorize
		},
		data() {
			return {
				list: [{
					image: 'https://zhcxservice.145u.net/Images/ZHCX/huodong1.png',
				}, {
					image: 'https://zhcxservice.145u.net/Images/ZHCX/shouye3.png',
				}, {
					image: 'https://zhcxservice.145u.net/Images/ZHCX/shouye3.png',
				}],
				imageArr: [],
				swiperIndex: 0,
				mainList: indexList.homeMainList,
				subList: indexList.homeSubList,
				mode: 'round',
				indicatorPos: 'bottomCenter',
				bindPhoneshow: false,
				effect3d: true,
				infoList: [{
					image: '../../static/home/rentInfo.png',
					title: '租车须知',
					subTitle: '接送机租车包车'
				}, {
					image: '../../static/home/request.png',
					title: '使用手册',
					subTitle: '购票流程展示'
				}],
				userInfo: [],
				optionParam: '',
				jsCode: '',
				openid: '',
				unionid: '',
				session_key: '',
				encryptedData: '',
				iv: '',
				platform: '',
				version: '',
				avatarUrl: '', //头像
				isAuthorize: false,
				jczData: {
					itemname: '机动车检测线',
					itemdata: [{
						affiliationname: '建阳天蓝机动车检测有限公司',
						tellnumber: '0599-8070695',
						rescuenumber: '',
						address: '南平市建阳区建阳嘉禾北路',
						scope: '机动车安全技术检验、汽车综合性能检验、机动车尾气排放环保检验',
					}, {
						affiliationname: '武夷山天蓝机动车检测有限公司',
						tellnumber: '13859330111',
						rescuenumber: '',
						address: '武夷山市五九北路64号',
						scope: '机动车安全技术检验、汽车综合性能检验、机动车尾气排放环保检验',
					}, {
						affiliationname: '浦城天蓝机动车检测有限公司',
						tellnumber: '0599-2828006',
						rescuenumber: '',
						address: '浦城县莲西路58号',
						scope: '机动车安全技术检验、汽车综合性能检验、机动车尾气排放环保检验',
					}, {
						affiliationname: '松溪天蓝机动车检测有限公司',
						tellnumber: '0599-6082333',
						rescuenumber: '',
						address: '松溪县工业路3号',
						scope: '机动车安全技术检验、汽车综合性能检验、机动车尾气排放环保检验',
					}, {
						affiliationname: '南平市机动车综合性能检测有限公司机动车登记服务站',
						tellnumber: '0599-8616806',
						rescuenumber: '',
						address: '南平市延平区环城中路102号',
						scope: '机动车安全技术检验、汽车综合性能检验、机动车尾气排放环保检验',
					}, ]
				},
				qxfwData: {
					itemname: '汽车维修和施救中心',
					itemdata: [{
						affiliationname: '武夷股份光泽分公司修理厂',
						tellnumber: '0595-7952118',
						rescuenumber: '13509515620',
						rescuenumber2: '17720693506',
						address: '光泽县杭川镇新兴街32号（旧址）,光泽县滨江大道（中路）63号新汽车站内（新址）',
						scope: '客、货车、乘用车维修、施救',
					}, {
						affiliationname: '武夷股份邵武分公司汽车修理厂',
						tellnumber: '13960689875',
						rescuenumber: '13960689875',
						address: '邵武解放西路113号',
						scope: '危险品运输车辆维修；客车维修；货车维修；汽车保管；停车场服务',
					}, {
						affiliationname: '顺昌天龙公交修理厂',
						tellnumber: '0599-6951180',
						rescuenumber: '15305997123',
						address: '顺昌县城南东路东19号',
						scope: '汽车修理、维护',
					}, {
						affiliationname: '建瓯市公交修理厂',
						tellnumber: '18050392933',
						rescuenumber: '18050392933',
						address: '建瓯市金瓯路58号',
						scope: '大中型客车维修',
					}, {
						affiliationname: '武夷股份建阳分公司修理厂',
						tellnumber: '0599-5823598',
						rescuenumber: '18950669949',
						address: '建阳嘉禾北路673-14',
						scope: '客车、货车维修',
					}, {
						affiliationname: '武夷股份武夷山分公司修理厂',
						tellnumber: '18960632909',
						rescuenumber: '18960632909',
						address: '武夷山市五九北路64号',
						scope: '客车维修，小型客车维修，货车维修，竣工检测，乘用车维修，竣工自检。',
					}, {
						affiliationname: '武夷股份浦城分公司修理厂',
						tellnumber: '13809591289',
						rescuenumber: '13809591289',
						address: '浦城县莲西路58号',
						scope: '汽车维修',
					}, {
						affiliationname: '武夷股份政和分公司修理厂',
						tellnumber: '13859479867',
						rescuenumber: '13859479867',
						address: '政和县西大街2号',
						scope: '客车、货车、小车维修',
					}, {
						affiliationname: '武夷股份松溪分公司修理厂',
						tellnumber: '13960653963',
						rescuenumber: '13960653963',
						address: '松溪县工业路3号',
						scope: '客车、货车维修',
					}, {
						affiliationname: '武夷股份汽车服务分公司修理厂',
						tellnumber: '0599-8624595',
						rescuenumber: '0599-8624595',
						address: '南平市延平区环城中路102号',
						scope: '大中型客车、大型货车、小型车、危险货物运输车辆维修',
					}, {
						affiliationname: '福建武夷交通运输股份有限公司道路交通施救分公司',
						tellnumber: '13706008585',
						rescuenumber: '13706008585',
						address: '南平市延平区环城中路102号',
						scope: '汽车拖车、救援、清障服务',
					}, ]
				},
				sfjdData: {
					itemname: '司法鉴定',
					itemdata: [{
						affiliationname: '福建天祥司法鉴定所（延平）',
						tellnumber: '0599-8631368',
						rescuenumber: '',
						address: '南平市延平区环城中路102号',
						scope: '痕迹鉴定（交通事故车辆痕迹鉴定、行驶轨迹鉴定、行驶速度鉴定）',
					}]
				},
				cdzData: {
					itemname: '新能源充电',
					itemdata: [{
						affiliationname: '延平',
						tellnumber: '18559508669',
						rescuenumber: '',
						address: '延平区环城中路102号',
						scope: '新能源汽车充电',
					}, {
						affiliationname: '光泽',
						tellnumber: '16605995882',
						tellnumber2: '17720693609',
						rescuenumber: '',
						address: '光泽县滨江大道（中路）63号公交总站内',
						scope: '新能源汽车充电',
					}, {
						affiliationname: '顺昌',
						tellnumber: '0599-6951178',
						rescuenumber: '',
						address: '顺昌县城南东路东19号',
						scope: '新能源汽车充电',
					}, {
						affiliationname: '建瓯',
						tellnumber: '13599317828',
						rescuenumber: '',
						address: '建瓯市建安路52号',
						scope: '新能源汽车充电',
					}, {
						affiliationname: '浦城',
						tellnumber: '0599-2882292',
						rescuenumber: '',
						address: '浦城县莲西路58号',
						scope: '新能源汽车充电',
					}, {
						affiliationname: '松溪',
						tellnumber: '0599-2321588',
						rescuenumber: '',
						address: '松溪县工业路3号',
						scope: '新能源汽车充电',
					}]
				},
			}
		},
		onLoad(option) {
			_self = this;
			//this.interstitialLoad(); //加载插屏广告
			// _self.getEquipmentInfo();
			// #ifdef MP-WEIXIN
			//监听授权状态
			uni.$on('changeAuthorize', function(data) {
				console.log(data);
				_self.isAuthorize = data.data;
				uni.$off('changeAuthorize');
			});
			// 若在开发者工具中无法预览广告，请切换开发者工具中的基础库版本
			// 在页面中定义插屏广告
			let interstitialAd = null
			
			// 在页面onLoad回调事件中创建插屏广告实例
			if (wx.createInterstitialAd) {
			  interstitialAd = wx.createInterstitialAd({
			    adUnitId: 'adunit-4d746f1536527369'
			  })
			  interstitialAd.onLoad(() => {})
			  interstitialAd.onError((err) => {
			    console.error('插屏广告加载失败', err)
			  })
			  interstitialAd.onClose(() => {})
			}
			
			// 在适合的场景显示插屏广告
			if (interstitialAd) {
			  interstitialAd.show().catch((err) => {
			    console.error('插屏广告显示失败', err)
			  })
			}
			// #endif
			_self.GetSystemModular();
			if (typeof option.q != 'undefined') {
				var url = decodeURIComponent(option.q).trim();
				_self.optionParam = this.getkcard(url, 'openid'); //获取链接参数
			}
			//获取小程序更新公告
			_self.getRenewMemo();




			// const updateManager = uni.getUpdateManager();
			// updateManager.onCheckForUpdate(function(res) {
			// 	// 请求完新版本信息的回调
			// 	if (res.hasUpdate) {
			// 		updateManager.onUpdateReady(function(res) {



			// 			uni.showModal({
			// 				title: '更新提示',
			// 				content: '新版本已经准备好，是否重启应用？',
			// 				success(res) {
			// 					if (res.confirm) {

			// 					}
			// 				}
			// 			});
			// 		});
			// 	}
			// });
			// updateManager.onUpdateFailed(function(res) {
			// 	uni.showModal({
			// 		title: '更新提示',
			// 		content: '更新失败，请手动删除小程序'
			// 	});
			// });

		},
		// onHide(){
		// 	console.log("onHide监听页面隐藏")
		// 		if (interstitialAd) {
		// 				interstitialAd.destroy();
		// 		}
		// },
		// onUnload(){
		// 	console.log("onUnload监听页面卸载")
		// 		if (interstitialAd) {
		// 				interstitialAd.destroy();
		// 		}
		// },
		onShow() {
			// #ifdef APP
			_self.judgeUserInfo();
			// #endif

			// #ifdef MP-WEIXIN
			uni.getStorage({
				key: 'userInfo',
				success: function(res) {
					console.log('用户信息111', res.data);
					_self.userInfo = res.data;
				},
				// fail: function() {
				// 	uni.$emit('getAuthorize', {
				// 		data: '授权'
				// 	});
				// }
			})
			uni.getStorage({
				key: 'WXOpenID',
				success(res) {
					console.log('2222', res);
					_self.openid = res.data;
					console.log('2222', _self.openid);
					console.log('2212', _self.optionParam);
					if (_self.optionParam) {
						_self.setPromoterLog(_self.optionParam, _self.openid);
					}
				}
			})
			// _self.userInfo = uni.getStorageSync('userInfo');
			_self.isAuthorize = uni.getStorageSync('isAuthorize');
			// #endif
			//this.interstitialShow(0); //显示插屏广告
		},
		methods: {
			getkcard: function(url, name) {
				var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
				var r = url.substr(1).match(reg)
				if (r != null) {
					return r[2]
				}
				return null;
			},
			getRenewMemo: function() {
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetRenewAnnouncementMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetRenewAnnouncementMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetRenewAnnouncementMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('更新提示', res)
						if (res.data.Success) {
							uni.showModal({
								title: '闽北行小程序更新公告',
								content: res.data.Data,
								confirmText: '已阅读',
								showCancel: false,
								success(res) {
									console.log(res);
									if (res.confirm) {
										const updateManager = uni.getUpdateManager();
										// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
										updateManager.applyUpdate();
									}
								}
							})
						} else {
							uni.getStorage({
								key: 'getrenewmemo',
								success: function(renewmemodata) {
									console.log('132456', renewmemodata);
									if (renewmemodata.data != res.data.Message) {
										uni.showModal({
											title: '闽北行小程序更新公告',
											content: res.data.Data,
											confirmText: '已阅读',
											showCancel: false,
											success(res) {
												console.log(res);
												if (res.confirm) {
													const updateManager = uni
														.getUpdateManager();
													// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
													updateManager.applyUpdate();
												}
											}
										})
										uni.setStorage({
											key: 'getrenewmemo',
											data: res.data.Message,
										})
									}
								},
								fail(faildata) {
									console.log('123465', faildata);
									uni.showModal({
										title: '闽北行小程序更新公告',
										content: res.data.Data,
										confirmText: '已阅读',
										showCancel: false,
										success(res) {
											console.log(res);
											if (res.confirm) {
												const updateManager = uni
												.getUpdateManager();
												// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
												updateManager.applyUpdate();
											}
										}
									})
									uni.setStorage({
										key: 'getrenewmemo',
										data: res.data.Message,
									})
								}
							})
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});



			},
			setPromoterLog: function(optionParam, openid) {
				console.log('4444', optionParam, _self.userInfo.Id, openid);
				uni.request({
					url: _self.$h.expressInterface.expressInterface.SetPromoterLog.url,
					method: _self.$h.expressInterface.expressInterface.SetPromoterLog.method,
					header: _self.$h.expressInterface.expressInterface.SetPromoterLog.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode
							.appSystemCode,
						PromoterOpenID: optionParam,
						OperatorOpenID: openid,
						OperatorID: _self.userInfo.Id,
					},
					success: (res) => {
						console.log('记录乘客操作成功返回数据', res);
					},
					fail(res) {
						console.log('记录乘客操作失败返回数据', res);
					}
				});
			},
			//---------------------------------------------版本更新---------------------------------------------
			GetAppVersion: function() {
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetAppVersion.url,
					method: _self.$h.expressInterface.expressInterface.GetAppVersion.method,
					header: _self.$h.expressInterface.expressInterface.GetAppVersion.header,
					data: {
						AppName: '南平综合出行旅客端'
					},
					success: function(res) {
						console.log('成功返回结果', res);
						console.log(_self.version, res.data.VersionCode);
						if (res.data) {
							if (_self.version < res.data.VersionCode) {
								uni.showModal({
									title: '温馨提示',
									content: '当前版本' + _self.version + '\n' + '发现新版本，是否前往更新',
									complete(res1) {
										if (res1.confirm) {
											let url = res.data.DownLoadUrl;
											plus.runtime.openURL(url, function(res) {
												console.log(res);
											});
										}
									}
								})
							}
						} else {

						}
					},
					fail: function(res) {
						console.log('失败返回', res);
					}
				})
			},
			//---------------------------------------------获取设备系统信息---------------------------------------------
			getEquipmentInfo: function() {
				//获取系统信息
				uni.getSystemInfo({
					success(res) {
						// console.log('获取系统信息', res)
						//获取系统平台 iOS Android
						_self.platform = res.platform;
						// 获取本地应用资源版本号  
						plus.runtime.getProperty(plus.runtime.appid, function(inf) {
							_self.version = inf.version; //获取当前版本号
							_self.GetAppVersion(inf.version);
						});
					}
				})
			},
			//---------------------------------------------快捷弹窗---------------------------------------------
			showToast: function(title, type) {
				_self.$refs.uToast.show({
					title: title,
					type: type
				})
			},
			//--------------------------------------轮播图点击--------------------------------------
			swiperClick: function(list) {
				// console.log(list[this.swiperIndex].image);
				if (_self.imageArr[this.swiperIndex].LinkImageUrl != '') {
					uni.navigateTo({
						url: '../../pages_IntercityExpress/subWebViewItem/AdContentsView?modularClickUrl=' +
							_self.imageArr[this.swiperIndex].ModularClickUrl +
							'&heightNumber=' + _self.imageArr[this.swiperIndex].HeightNumber +
							'&linkImageUrl=' + _self.imageArr[this.swiperIndex].LinkImageUrl +
							'&isClick=' + _self.imageArr[this.swiperIndex].IsClick
					})
				}
				// if (this.swiperIndex == 0) {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/subWebViewItem/hotLineView'
				// 	})
				// }
				// if (this.swiperIndex == 1) {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/subWebViewItem/imageView'
				// 	})
				// }
				// if (this.swiperIndex == 2) {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/subWebViewItem/huodongView'
				// 	})
				// }
				// if (this.swiperIndex == 3) {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/subWebViewItem/priceView'
				// 	})
				// }
				// if (this.swiperIndex == 4) {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/subWebViewItem/textMessageView'
				// 	})
				// }
				// uni.clearStorage('isAuthorize')
			},
			swiperChange: function(e) {
				this.swiperIndex = e;
			},
			//--------------------------------------获取模块信息--------------------------------------
			GetSystemModular: function() {
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetSystemModular.url,
					method: _self.$h.expressInterface.expressInterface.GetSystemModular.method,
					header: _self.$h.expressInterface.expressInterface.GetSystemModular.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode
							.appSystemCode
					},
					success: (res) => {
						// console.log(res); 
						// console.log('获取模块信息',JSON.parse(res.data.Data));
						var modularArr = JSON.parse(res.data.Data).filter(item => {
							return item.Type == '首页'
						});
						_self.imageArr = JSON.parse(res.data.Data).filter(item => {
							return item.Type == '轮播图'
						});
						console.log(_self.imageArr);
						if (_self.imageArr.length > 0) {
							_self.list = [];
							for (var i = 0; i < _self.imageArr.length; i++) {
								if (_self.imageArr[i].IsOpen == true) {
									var image = _self.imageArr[i].ModularLink;
									_self.list.push(image);
								}
							}
						}
						for (var i = 0; i < modularArr.length; i++) {
							for (var j = 0; j < _self.subList.length; j++) {
								if (modularArr[i].ModularName == _self.subList[j].name) {
									_self.subList[j].isClick = modularArr[i].IsOpen;
									_self.subList[j].url = modularArr[i].ModularLink;
								}
							}
						}
						// console.log(_self.subList);
					},
					fail(res) {
						console.log('获取模块信息', res);
					}
				});
			},
			sendTemMessage() {
				///发起消息订阅
				uni.requestSubscribeMessage({
					tmplIds: ['vR3Y5CQ2zMWZIiJdGnFm3u8011moZZhOljn-m_MeL2Y'], //这里填入我们生成的模板id
					success: (res) => {
						if (res['vR3Y5CQ2zMWZIiJdGnFm3u8011moZZhOljn-m_MeL2Y'] === 'accept') {
							// wx.showToast({
							// 	title: '订阅成功！',
							// 	icon: 'success'
							// })
						} else if (res['vR3Y5CQ2zMWZIiJdGnFm3u8011moZZhOljn-m_MeL2Y'] == 'reject') {
							wx.showModal({
								title: '订阅消息',
								content: '为更好的让您了解订单信息，服务号需要在您的订单操作时向您推送消息，您当前拒绝接受消息通知，是否去开启',
								confirmText: '开启授权',
								confirmColor: '#345391',
								cancelText: '仍然拒绝',
								cancelColor: '#999999',
								success(res) {
									if (res.confirm) {
										// console.log('用户点击确定')
										wx.openSetting({
											success(res) {
												console.log(res.authSetting)
											},
											fail(err) {
												//失败
												console.log(err)
											}
										})
									} else if (res.cancel) {
										console.log('用户点击取消')
									}
								}
							})
						}
					},
					fail: (errCode, errMessage) => {
						console.log("订阅失败", errMessage)
					},
					complete: (errMsg) => {
						console.log("订阅完成", errMsg)
					}

				});
			},
			mainItemClick: function(item) {
				if (item.name != '购票历史') {
					_self.sendTemMessage();
				}
				//记录用户点击操作
				_self.GetModularOperationLog(item.name);
				if (!item.isClick) {
					_self.showToast('该功能正在开发中...', 'warning')
				} else if (item.name == '公交查询') {
					// uni.navigateTo({
					// 	url: item.clickUrl
					// })
					uni.navigateTo({
						url: '../../pages_IntercityExpress/subWebViewItem/publicWebview?name=' +
							item.name +
							'&url=' + item.url
					})
				} else {
					//未登录不可用操作在App.vue中做了拦截操作
					// #ifdef MP-WEIXIN
					uni.getStorage({
						key: 'userInfo',
						success: function(res) {
							_self.userInfo = res.data;
							if (item.name == '购票历史') {
								uni.switchTab({
									url: '../Order/Order'
								})
							} else {
								uni.navigateTo({
									url: item.clickUrl
								})
							}
							
						},
						fail: function() {
							uni.$emit('getAuthorize', {
								data: '授权'
							});
						}
					})
					// _self.userInfo = uni.getStorageSync('userInfo');
					_self.isAuthorize = uni.getStorageSync('isAuthorize');
					// #endif

				}
			},
			subClick: function(item) {
				//记录用户点击操作
				_self.GetModularOperationLog(item.name);
				if (item.name == '热门线路') {
					// #ifdef MP-WEIXIN
					uni.getStorage({
						key: 'userInfo',
						success: function(res) {
							console.log('用户信息', res.data);
							_self.userInfo = res.data;
							uni.navigateTo({
								url: '../../pages_IntercityExpress/HotLine/HotLine'
							})
						},
						fail: function() {
							uni.$emit('getAuthorize', {
								data: '授权'
							});
						}
					})
					// _self.userInfo = uni.getStorageSync('userInfo');
					_self.isAuthorize = uni.getStorageSync('isAuthorize');
					// #endif

					return
				}
				if (item.name == '武夷新区专线') {
					// #ifdef MP-WEIXIN
					uni.getStorage({
						key: 'userInfo',
						success: function(res) {
							console.log('用户信息', res.data);
							_self.userInfo = res.data;
							uni.navigateTo({
								url: '../../pages_IntercityExpress/wuYiXinQuZhuanXian/wuYiXinQuZhuanXian'
							})
						},
						fail: function() {
							uni.$emit('getAuthorize', {
								data: '授权'
							});
						}
					})
					// _self.userInfo = uni.getStorageSync('userInfo');
					_self.isAuthorize = uni.getStorageSync('isAuthorize');
					// #endif

					return
				}
				if (item.name == '城际快线') {
					// #ifdef MP-WEIXIN
					uni.getStorage({
						key: 'userInfo',
						success: function(res) {
							console.log('用户信息', res.data);
							_self.userInfo = res.data;
							uni.navigateTo({
								url: '../../pages_IntercityExpress/intercityExpressLine/intercityExpressLine'
							})
						},
						fail: function() {
							uni.$emit('getAuthorize', {
								data: '授权'
							});
						}
					})
					// _self.userInfo = uni.getStorageSync('userInfo');
					_self.isAuthorize = uni.getStorageSync('isAuthorize');
					// #endif

					return
				}
				if (item.name == '校园巴士') {
					// #ifdef MP-WEIXIN
					uni.getStorage({
						key: 'userInfo',
						success: function(res) {
							console.log('用户信息', res.data);
							_self.userInfo = res.data;
							uni.navigateTo({
								url: '../../pages_IntercityExpress/SchoolBusHome/SchoolBusHome'
							})
						},
						fail: function() {
							uni.$emit('getAuthorize', {
								data: '授权'
							});
						}
					})
					// _self.userInfo = uni.getStorageSync('userInfo');
					_self.isAuthorize = uni.getStorageSync('isAuthorize');
					// #endif

					return
				}
				if (item.name == '乡镇客运') {
					// #ifdef MP-WEIXIN
					//_self.showToast('该功能正在开发中...', 'warning')
					uni.navigateTo({
						url: '../../pages_IntercityExpress/townshipTransport/townshipTransport'
					})
					// #endif
					return
				}
				if (item.name == '天龙出行') {
					uni.navigateToMiniProgram({
						// appId: 'wx433c6be0c0db6708',
						appId: 'wxdf10b69f06bfeaee', 
					});
					return
				}
				if (item.name == '机场专线') {
					// _self.bindPhoneshow = true;
					uni.navigateTo({
						url: '../../pages_IntercityExpress/subWebViewItem/flightTicketHome'
					})
					return
				}
				if (item.name == '在线客服') {
					// _self.bindPhoneshow = true;
					uni.navigateTo({
						url: '../../pages_IntercityExpress/customerService/customerService'
					})
					return
				}
				if (item.name == '业务展示') {
					// _self.bindPhoneshow = true;
					uni.navigateTo({
						url: '../../pages_IntercityExpress/businessService/businessService'
					})
					return
				}
				if (item.name == '旅游包车') {
					uni.navigateTo({
						url: '../../pages_CharteredBus/Index/Index'
					})
					return

				}
				// if (item.name == '检测预约') {
				// 	uni.navigateTo({
				// 		url: '../../pages_IntercityExpress/businessService/businessdetails?data=' + decodeURIComponent(JSON.stringify(_self.jczData))
				// 	})
				// 	return
				// }
				if (item.name == '汽修服务') {
					uni.navigateTo({
						url: '../../pages_IntercityExpress/businessService/businessdetails?data=' +
							decodeURIComponent(JSON.stringify(_self.qxfwData))
					})
					return
				}
				if (item.name == '司法鉴定') {
					uni.navigateTo({
						url: '../../pages_IntercityExpress/businessService/businessdetails?data=' +
							decodeURIComponent(JSON.stringify(_self.sfjdData))
					})
					return
				}
				if (item.name == '充电桩') {
					uni.navigateTo({
						url: '../../pages_IntercityExpress/businessService/businessdetails?data=' +
							decodeURIComponent(JSON.stringify(_self.cdzData))
					})
					return
				}
				if (item.name == '火车') {
					uni.navigateToMiniProgram({
						appId: 'wxa51f55ab3b2655b9',
					});
					return
				}
				if (item.name == '航班') {
					uni.navigateToMiniProgram({
						appId: 'wx433c6be0c0db6708',
					});
					return
				}
				if (!item.isClick || item.name == '小件快递') {
					_self.showToast('该功能正在开发中...', 'warning')
				} else {
					uni.navigateTo({
						url: '../../pages_IntercityExpress/subWebViewItem/publicWebview?name=' +
							item.name +
							'&url=' + item.url
					})
				}
			},
			//--------------------------------------记录用户操作--------------------------------------
			GetModularOperationLog: function(ModularName) {
				// console.log(_self.userInfo);
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetModularOperationLog.url,
					method: _self.$h.expressInterface.expressInterface.GetModularOperationLog
						.method,
					header: _self.$h.expressInterface.expressInterface.GetModularOperationLog
						.header,
					data: {
						// PhoneNumber: _self.userInfo.PhoneNumber,
						ModularName: ModularName,
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode
							.appSystemCode,
					},
					success: (res) => {
						console.log('记录乘客操作成功返回数据', res);
					},
					fail(res) {
						console.log('记录乘客操作失败返回数据', res);
					}
				});
			},
			GetParamValueByName: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetParamValueByName.url,
					method: _self.$h.expressInterface.expressInterface.GetParamValueByName.method,
					header: _self.$h.expressInterface.expressInterface.GetParamValueByName.header,
					data: {
						ParamName: '首页轮播图'
					},
					success: (res) => {
						console.log('详情', res);
						uni.hideLoading();
						if (res.data.Success) {
							// _self.htmlText = JSON.parse(res.data.Data);
							_self.htmlText = res.data.Data;
						} else {
							_self.showToast(res.data.Message, 'warning');
						}
					},
					fail: function(res) {
						uni.hideLoading();
						console.log(res);
						_self.showToast('服务器错误', 'error');
					}
				})
			},
			//-------------------------------------------判断用户是否登陆-------------------------------------------
			judgeUserInfo: function() {
				uni.getStorage({
					key: 'userInfo',
					success: function(res) {
						console.log('用户信息', res.data);
						_self.userInfo = res.data;
						_self.isAuthorize = true;
					},
					fail: function(res) {
						_self.isAuthorize = false;
						// uni.navigateTo({
						// 	url:'../Login/Login'
						// })
						console.log(res);
					}
				})
			},
			call: function() {
				//呼叫客服1
				let that = this;
				uni.makePhoneCall({
					phoneNumber: '13328513020'
				});
			},
			call1: function() {
				//呼叫客服2
				let that = this;
				uni.makePhoneCall({
					phoneNumber: '0599-968951'
				});
			},
			//-------------------------------------------点击出行百宝箱-------------------------------------------
			treasureChestClick: function(item) {
				console.log(item);
				if (item.title == '使用手册') {
					uni.navigateTo({
						url: '../Mine/userManual/userManual'
					})

				} else {
					_self.showToast('功能暂未开放', 'warning');
				}

				// uni.navigateTo({
				// 	url:'../Taxi/taxiHome/taxiHome'
				// })
			},
			destroyAd() { //卸载插屏广告
				if (interstitialAd) {
					interstitialAd.destroy();
				}
			},
			interstitialLoad() { //加载插屏广告
				var that = this;
				var id = "adunit-4d746f1536527369";
				if (uni.createInterstitialAd) {
					interstitialAd = uni.createInterstitialAd({
						adUnitId: id
					})
					interstitialAd.onLoad(() => { //监听插屏广告加载事件
						console.log('插屏 广告加载成功')
						_self.interstitialShow(0);
					})
					interstitialAd.onError((err) => { //监听插屏错误事件
						console.log('插屏 广告加载失败', err)
					})
					interstitialAd.onClose((e) => { //监听插屏广告关闭事件
						console.log('插屏 广告关闭', e)
						//这里可以做关闭广告后想做的操作
					})
				}
			},
			interstitialShow(times) { //显示插屏广告
				var that = this;
				setTimeout(() => {
					if (interstitialAd) {
						console.log('插屏广告正在显示....');
						interstitialAd.show().catch((err) => {
							console.error("插屏广告显示失败：", err);
							switch (err.errCode) {
								case 2001:
									//打开小程序一定时间内不允许展示
									that.interstitialShow(1000);
									break;
								case 2002:
									//距离小程序插屏广告或者激励视频广告上次播放时间间隔不足，不允许展示插屏广告
									that.interstitialShow(1000);
									break;
								default:
									break;
							}
						})
					}
				}, times)
			},
		}
	}
</script>

<style lang="scss">
	.guess-section {
		display: flex;
		flex-wrap: wrap;
		padding: 0 30rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}

	.title {
		margin-top: 10rpx;
		margin-left: 10rpx;
		font-size: 30rpx;
		font-weight: 300;
		color: #333;
		line-height: 45rpx;
		display: block;
		text-overflow: ellipsis;
		// white-space: nowrap;
		overflow: hidden;
		width: 160px;
	}

	.guess-item {
		display: flex;
		flex-direction: column;
		width: 48%;
		background-color: #FFFFFF;
		padding-bottom: 40upx;
		border-radius: 20rpx;

		&:nth-child(2n+1) {
			margin-right: 4%;
		}
	}

	.image {
		width: 100%;
		height: 360rpx;
		// border-radius: 3px;
		overflow: hidden;
		border-radius: 20rpx;
		//0向右偏移量 2阴影向下偏移量 2边框模糊度 0.1透明度
		box-shadow: 0px 2px 5px 0.1px #AAAAAA;
	}

	.float-button {
		position: fixed;
		right: 0px;
		bottom: 150px;
		color: #FFF;
		width: 35px;
		/* height: 55px; */
		/* border-radius: 30%; */
		background: #4A98EA;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.4);
		z-index: 999;
	}
</style>